/**
 * @filename:PackageTypeServiceImpl 2019-01-17 14:56:43
 * @project skz  V1.3.3
 * Copyright(c) 2018 Liu,Wenzhao Co. Ltd. 
 * All right reserved. 
 */
package com.bingsum.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import com.github.pagehelper.PageHelper;

import java.util.List;

import com.bingsum.model.PackageType;
import com.bingsum.mapper.PackageTypeMapper;

/**   
 *  
 * @Description:  [包裹类型]——SERVICE
 * @Author:       Liu,Wenzhao   
 * @CreateDate:   2019-01-17 14:56:43
 * @Version:      V1.3.3
 *    
 */
@Service("packageTypeService")
@Transactional(readOnly = true)
public class PackageTypeService{

    @Autowired
    private PackageTypeMapper packageTypeMapper;
	
    public List<PackageType> getAll(PackageType packageType) {
        if (packageType.getPage() != null && packageType.getRows() != null) {
            PageHelper.startPage(packageType.getPage(), packageType.getRows());
        }
        return packageTypeMapper.selectAll();
    }

    public PackageType getById(Integer id) {
        return packageTypeMapper.selectByPrimaryKey(id);
    }
    
    @Transactional(readOnly = false)
    public void deleteById(Integer id) {
        packageTypeMapper.deleteByPrimaryKey(id);
    }

    @Transactional(readOnly = false)
    public void save(PackageType packageType) {
        if (packageType.getId() != null) {
            packageTypeMapper.updateByPrimaryKey(packageType);
        } else {
            packageTypeMapper.insert(packageType);
        }
    }
}